package com.simen.hellobytes;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @author Created by Simen.
 * @date 创建日期 2018/5/9 11:12
 * @modify 修改者 Simen
 */
public class StringUtil {

    public static boolean isNotEmpty(String str) {
        return !isEmpty(str);
    }

    public static boolean isEmpty(String str) {
        return str == null || str.length()==0;
    }

    public static boolean isEmptys(String... str){
        if(str==null || str.length==0){
            return true;
        }

        for (int i = 0; i < str.length; i++) {
            if(isEmpty(str[i])){
                return true;
            }
        }

        return false;
    }

    public static boolean isTrimNotEmpty(String str){
        return !isTrimEmpty(str);
    }

    public static boolean isTrimEmpty(String str) {
        return str == null || str.trim().length()==0;
    }

    public static boolean areTrimEmpty(String... str){
        if(str==null || str.length==0){
            return true;
        }

        for (int i = 0; i < str.length; i++) {
            if(isTrimEmpty(str[i])){
                return true;
            }
        }

        return false;
    }

    public static boolean isMapEmpty(Map map){
        if(map==null || map.isEmpty()){
            return true;
        }

        return false;
    }

    public static boolean isListEmpty(List list){
        return isCollectionEmpty(list);
    }

    public static boolean isCollectionEmpty(Collection collection){
        if(collection==null || collection.isEmpty()){
            return true;
        }

        return false;
    }

}
